package com.vibration.web.controller.baseinfo;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vibration.common.annotation.Log;
import com.vibration.common.core.controller.BaseController;
import com.vibration.common.core.domain.AjaxResult;
import com.vibration.common.enums.BusinessType;
import com.vibration.baseinfo.domain.CzTaskData;
import com.vibration.baseinfo.service.ICzTaskDataService;
import com.vibration.common.utils.poi.ExcelUtil;
import com.vibration.common.core.page.TableDataInfo;

/**
 * 任务数据Controller
 * 
 * @author wu
 * @date 2022-08-11
 */
@RestController
@RequestMapping("/baseinfo/taskData")
public class CzTaskDataController extends BaseController
{
    @Autowired
    private ICzTaskDataService czTaskDataService;

    /**
     * 查询任务数据列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzTaskData czTaskData)
    {
        startPage();
        List<CzTaskData> list = czTaskDataService.selectCzTaskDataList(czTaskData);
        return getDataTable(list);
    }

    /**
     * 导出任务数据列表
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:export')")
    @Log(title = "任务数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzTaskData czTaskData)
    {
        List<CzTaskData> list = czTaskDataService.selectCzTaskDataList(czTaskData);
        ExcelUtil<CzTaskData> util = new ExcelUtil<CzTaskData>(CzTaskData.class);
        util.exportExcel(response, list, "任务数据数据");
    }

    /**
     * 获取任务数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(czTaskDataService.selectCzTaskDataById(id));
    }

    /**
     * 新增任务数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:add')")
    @Log(title = "任务数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzTaskData czTaskData)
    {
        return toAjax(czTaskDataService.insertCzTaskData(czTaskData));
    }

    /**
     * 修改任务数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:edit')")
    @Log(title = "任务数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzTaskData czTaskData)
    {
        return toAjax(czTaskDataService.updateCzTaskData(czTaskData));
    }

    /**
     * 删除任务数据
     */
    @PreAuthorize("@ss.hasPermi('baseinfo:taskData:remove')")
    @Log(title = "任务数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(czTaskDataService.deleteCzTaskDataByIds(ids));
    }
}
